
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
  <head>
    <title>学生管理-编辑</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/bootstrap/bootstrap.min.css" media="all">
    <style>
      .layui-form-select {
        width: 100% !important;
      }
      
      .layui-form-select .layui-input {
        height: 32px;
      }
    </style>
  </head>
  <body class="m-3" style="font-size: 0.8rem;">
    <div class="d-flex flex-column layui-form">
      <div class="d-flex mb-4">
        <div class="col d-flex">
          <label class="d-flex align-items-center" style="width: 80px;margin: 0px;">所属班级:</label>
          <input id="calssId" value="${editStudent.calssId}" type="hidden"/>
          <input id="stuId" value="${editStudent.stuId}" type="hidden"/>
          <select name="selectClass" lay-filter="selectClass">
            <option value=""></option>
            <c:forEach items="${editClassesList}" var="item">
              <option value="${item.calssId}"
                      <c:if test="${item.calssId == editStudent.calssId}">selected</c:if>>${item.calssName}</option>
            </c:forEach>
            <%--            <option value="2">游戏</option>--%>
            <%--            <option value="3">音乐</option>--%>
            <%--            <option value="4">旅行</option>--%>
          </select>
        </div>
        <div class="col d-flex align-items-center">
          <label class="d-flex align-items-center" style="width: 80px;margin: 0px;">姓名:</label>
          <input id="stuName" class="form-control form-control-sm" value="${editStudent.stuName}" placeholder="请输入学生姓名"/>
        </div>
      </div>
      <div class="d-flex mb-4">
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">电话:</label>
          <input class="form-control form-control-sm" placeholder="请输入电话号码" id="phone" value="${editStudent.phone}"/>
        </div>
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">身份证号:</label>
          <input class="form-control form-control-sm" placeholder="请输入身份证号" id="idCard" value="${editStudent.idCard}"/>
        </div>
      </div>
      <div class="d-flex mb-4">
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">入学年份:</label>
          <input class="form-control form-control-sm" placeholder="请输入入学年份" id="joinYear" value="${editStudent.joinYear}"/>
        </div>
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">性别:</label>
          <input type="radio"
                 <c:if
                   test="${editStudent.sex == '男'}">checked="checked"</c:if> class="form-control form-control-sm" name="sex" value="男" title="男"/>
          <input type="radio" class="form-control form-control-sm"
                 <c:if test="${editStudent.sex == '女'}">checked="checked"</c:if> name="sex" value="女" title="女"/>
        </div>
      </div>
      <div class="d-flex mb-4">
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">学号:</label>
          <input class="form-control form-control-sm" placeholder="请输入学号" id="stuNum" value="${editStudent.stuNum}"/>
        </div>
        <div class="col d-flex">
          <label style="margin: 0px;width: 80px;" class="d-flex align-items-center">登录密码:</label>
          <input class="form-control form-control-sm" placeholder="请输入登录密码" id="password" value="${editStudent.password}"/>
        </div>
      </div>
    </div>
    <script src="${pageContext.request.contextPath}/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/lay-config.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/http.js" charset="utf-8"></script>
    <script>
        var layer = null;
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            layer = layui.layer;
            //专业选择的监听
            form.on('select(selectClass)', function (data) {
                //设置选择的班级的id
                console.log(data)
                $("#calssId").val(data.value)
            })
        })

        //表单提交数据
        function addParms() {
            //班级
            var calssId = $("#calssId").val();
            if (!calssId) {
                layer.msg('请选择班级');
                return;
            }
            //姓名
            var stuName = $("#stuName").val();
            if (!stuName) {
                layer.msg('请填写学生姓名');
                return;
            }
            //电话
            var phone = $("#phone").val();
            if (!phone) {
                layer.msg('请填写学生电话');
                return;
            }
            //身份证
            var idCard = $("#idCard").val();
            if (!idCard) {
                layer.msg('请填写身份证号码');
                return;
            }
            //入学年份
            var joinYear = $("#joinYear").val();
            if (!joinYear) {
                layer.msg('请填写入学年份');
                return;
            }
            //性别
            var sex = $("input[name='sex']:checked").val();
            if (!sex) {
                layer.msg('请选择性别');
                return;
            }
            //学号
            var stuNum = $("#stuNum").val();
            if (!stuNum) {
                layer.msg('请填写学号');
                return;
            }
            //密码
            var password = $("#password").val();
            if (!password) {
                layer.msg('请填写登录密码');
                return;
            }
            return {
                stuId:$("#stuId").val(),
                calssId: calssId,
                stuName: stuName,
                phone: phone,
                idCard: idCard,
                sex: sex,
                stuNum: stuNum,
                password: password,
                joinYear: joinYear
            }
        }
    </script>
  </body>
</html>
